﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Famofo.AgbaraVOIP.OutboundServer
{
    public class Params
    {
        public Dictionary<string, Dictionary<string, string>> ELEMENTS_DEFAULT_PARAMS = new Dictionary<string, Dictionary<string, string>>();
        public Params()
        {
            ELEMENTS_DEFAULT_PARAMS.Add("Conference", Conference());
            ELEMENTS_DEFAULT_PARAMS.Add("Dial", Dial());
            ELEMENTS_DEFAULT_PARAMS.Add("GetDigits", GetDigits());
            ELEMENTS_DEFAULT_PARAMS.Add("Hangup", Hangup());
            ELEMENTS_DEFAULT_PARAMS.Add("Number", Number());
            ELEMENTS_DEFAULT_PARAMS.Add("Wait", Wait());
            ELEMENTS_DEFAULT_PARAMS.Add("Play", Play());
            ELEMENTS_DEFAULT_PARAMS.Add("PreAnswer", PreAnswer());
            ELEMENTS_DEFAULT_PARAMS.Add("Record", Record());
            ELEMENTS_DEFAULT_PARAMS.Add("Redirect", Redirect());
            ELEMENTS_DEFAULT_PARAMS.Add("Speak", Speak());
        }
        private Dictionary<string, string> Conference()
        {
            Dictionary<string, string> param = new Dictionary<string, string>();
            //'room': SET IN ELEMENT BODY
            param.Add("waitSound", "");
            param.Add("muted", "false");
            param.Add("startConferenceOnEnter", "true");
            param.Add("endConferenceOnExit", "false");
            param.Add("maxMembers", "200");
            param.Add("enterSound", "");
            param.Add("exitSound", "");
            param.Add("timeLimit", "0");
            param.Add("hangupOnStar", "false");
            param.Add("recordFilePath", "");
            param.Add("recordFileFormat", "mp3");
            param.Add("recordFilePrefix", "");

            return param;
        }
        private Dictionary<string, string> Dial()
        {
            Dictionary<string, string> param = new Dictionary<string, string>();
            //action: DYNAMIC! MUST BE SET IN METHOD,
            param.Add("method", "POST");
            param.Add("hangupOnStar", "false");
            //callerId: DYNAMIC! MUST BE SET IN METHOD,
            param.Add("timeLimit", "0");
            param.Add("confirmSound", "");
            param.Add("confirmKey", "");
            param.Add("dialMusic", "");

            return param;
        }
        private Dictionary<string, string> GetDigits()
        {
            Dictionary<string, string> param = new Dictionary<string, string>();
            //action: DYNAMIC! MUST BE SET IN METHOD,
            param.Add("method", "POST");
            param.Add("timeout", "5");
            param.Add("finishOnKey", "#");
            param.Add("numDigits", "99");
            param.Add("retries", "1");
            param.Add("playBeep", "false");
            param.Add("validDigits", "0123456789*#");
            param.Add("invalidDigitsSound", "");

            return param;
        }
        private Dictionary<string, string> Hangup()
        {
            Dictionary<string, string> param = new Dictionary<string, string>();
            param.Add("reason", "");
            param.Add("schedule", "0");
            return param;
        }
        private Dictionary<string, string> Number()
        {
            Dictionary<string, string> param = new Dictionary<string, string>();
           /* #'gateways': DYNAMIC! MUST BE SET IN METHOD,
                #'gatewayCodecs': DYNAMIC! MUST BE SET IN METHOD,
                #'gatewayTimeouts': DYNAMIC! MUST BE SET IN METHOD,
                #'gatewayRetries': DYNAMIC! MUST BE SET IN METHOD,
                #'extraDialString': DYNAMIC! MUST BE SET IN METHOD,*/
            param.Add("sendDigits", "");
            return param;
        }
        private Dictionary<string, string> Wait()
        {
            Dictionary<string, string> param = new Dictionary<string, string>();
            param.Add("lenght", "1");
            return param;
        }
        private Dictionary<string, string> Play()
        {
            Dictionary<string, string> param = new Dictionary<string, string>();
            //url: DYNAMIC! MUST BE SET IN METHOD,
            param.Add("loop", "1");
            return param;
        }
        private Dictionary<string, string> PreAnswer()
        {
            Dictionary<string, string> param = new Dictionary<string, string>();

            return param;
        }
        private Dictionary<string, string> Record()
        {
            Dictionary<string, string> param = new Dictionary<string, string>();
            param.Add("timeout", "5");
            param.Add("finishOnKey", "0123456789*#");
            param.Add("maxLength", "60");
            param.Add("playBeep", "true");
            param.Add("filePath", "/usr/local/freeswitch/recordings/");
            param.Add("format", "mp3");
            param.Add("prefix", "");
            param.Add("bothLegs", "false");

            return param;
        }
        private Dictionary<string, string> Redirect()
        {
            Dictionary<string, string> param = new Dictionary<string, string>();
            param.Add("method", "POST");

            return param;
        }
        private Dictionary<string, string> Speak()
        {
            Dictionary<string, string> param = new Dictionary<string, string>();
            param.Add("voice", "slt");
            param.Add("language", "en");
            param.Add("loop", "1");
            param.Add("engine", "flite");
            param.Add("method", "");
            param.Add("type", "");

            return param;
        }
    }
    
    
    public class Elements
    {
        private List<string>nestables;
        private Dictionary<string,string> attributes;
        private string text;
        private List<string> children;
        public Elements()
        {
            Params pa;
        }

        
    }
}
